import mongoose from '../config/DBHelper'
import moment from 'moment'
const Schema = mongoose.Schema
const LinksSchema = new Schema({
  title: { type: String },
  link: { type: String },
  created: { type: Date },
  type: { type: String, default: 'link' },
  isTop: { type: Number, default: 0 },
  sort: { type: Number, default: 0 }
})

LinksSchema.pre('save', function (next) {
  this.created = moment().format('YYYY-MM-DD HH:mm:ss')
  next()
})

const Links = mongoose.model('links', LinksSchema)

export default Links
